[Data]
life = 1000
attack = 100
defence = 100
fall.defence_up = 50
liedown.time = 60
airjuggle = 25
sparkno = S6001
guard.sparkno = -1
KO.echo = 0
volume = 0
IntPersistIndex = 0
FloatPersistIndex = 0

[Size]
xscale = 1
yscale = 1
ground.back = 0
ground.front = 0
air.back = 0
air.front = 0
height = 0
attack.dist = 0
proj.attack.dist = 0
proj.doscale = 2
head.pos = -1, -48
mid.pos = -1, -30
shadowoffset = 0
draw.offset = 0,0

[Velocity]
walk.fwd  = 0
walk.back = 0
run.fwd  = 0,0
run.back = 0,0
jump.neu = 0,0
jump.back = 0
jump.fwd = 0
runjump.back = 0,0
runjump.fwd = 0,0
airjump.neu = 0
airjump.back = 0
airjump.fwd = 0

[Movement]
airjump.num = 0
airjump.height = 0
yaccel = .44
stand.friction = .85
crouch.friction = .82

[Quotes]
victory1 = "wait DON'T LOOK AT ME I'M NAKED"
;---------------------------------------------------------------------------
;Var List

;***Universal***
;var(0) = Command variable
;var(1) = Famicom Fighters character detection
;var(2) = First hit counter

;var(24) = Test Var
;var(25) = Death State Check
;var(27) = Test Var
;var(32) = Intro Countdown
;fvar(20) = Vel X
;fvar(21) = Vel Y
;fvar(22) = Pos X
;fvar(23) = Pos Y
;fvar(24) = Test Var
;fvar(30) = Special projectile Vel X
;fvar(31) = Special projectile Vel Y
;fvar(32) = Super projectile Vel X
;fvar(33) = Super projectile Vel Y
;fvar(34) = Helper projectile Vel X
;fvar(35) = Helper projectile Vel Y
;fvar(36) = Helper Vel X
;fvar(37) = Helper Vel Y

;***Specific***
;var(3) = Score
;var(4) = Spinies Left
;var(5) = Simul/No AI Detection

;***Helpers***
;Universal
;var(0) = Non-active timer
;Green Spiny
;fvar(0) = Velocity var
;Red Spiny
;var(1) = Spiny easter egg var

;---------------------------------------------------------------------------
; INTRO 
[Statedef 191]
type = S
ctrl = 0
anim = 1
sprpriority = 5

[State 191, 1]
type = AssertSpecial
trigger1 = Time < 180
flag = Intro

[State 191, 2]
type = Helper
trigger1 = !Time && !Var(5)
name = "Lakitu"
ID = 1
stateno = 2
pos = 0,-35
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0

[State 191, 3]
type = AssertSpecial
trigger1 = Var(5) 
flag = invisible

[State 191, 4]
type = ChangeState
trigger1 = Time = 180
value = 0
;---------------------------------------------------------------------------
;Initialize
[Statedef 0]
type = S
movetype = I
physics = N
anim = 1
sprpriority = 0
ctrl = 0

[State 0, 1]
type = ScreenBound
trigger1 = !Var(5)
value = 0

[State 0, 2]
type = Helper
trigger1 = !Time && !NumHelper(1) && !Var(5)
name = "Lakitu"
ID = 1
stateno = 3
pos = 0,-35
postype = p1
facing = 1
keyctrl = 0
ownpal = 0

[State 0, 6]
type = VarSet
trigger1 = !Time && !Var(5)
var(4) = 0+(10*(RoundNo = 1))+(20*(RoundNo = 2))+(30*(RoundNo >= 3))

[State 0, 7]
type = ChangeState
trigger1 = RoundState = 2 && enemy,Ctrl = 1
value = 1

[State 0, 8]
type = ChangeState
trigger1 = RoundState = 2 && Var(5)
value = 5150
;---------------------------------------------------------------------------
;Initialize
[Statedef 1]
type = S
movetype = I
physics = N
anim = 1
sprpriority = 0
ctrl = 0

[State 1, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 1, 2]
type = PosSet
trigger1 = !Time
x = 200

[State 1, 3]
type = Turn
trigger1 = (Pos X <= 0 && Facing = -1) || (Pos X > 0 && Facing = 1)

[State 1, 4]
type = PosSet
trigger1 = enemynear(0),Facing != Facing && enemynear(0),Vel X < 0 && enemynear(0),Ctrl ;&& enemynear(0),Time >= 5
x = Cond(Pos X <= 0, 200,-200)

[State 1, 5]
type = PosSet
trigger1 = 1
x = Cond(pos x <= 0, -200, 200)

[State 0, LifeSet]
type = ChangeState
trigger1 = Var(4) = 0 && !NumHelper(10)
value = 5150

;---------------------------------------------------------------------------
;Lakitu
[Statedef 2]
type = A
physics = N
anim = 0
sprpriority = 0
ctrl = 0

[State 2, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 2, 2] 
type = ChangeState
trigger1 = RoundState = 2
value = 3
;---------------------------------------------------------------------------
;Lakitu
[Statedef 3]
type = A
physics = N
anim = 3
sprpriority = 0
ctrl = 0

[State 3, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 3, 2]
type = VelSet
trigger1 = AnimElem = 2
x = 3.2

[State 3, 3]
type = VelAdd
trigger1 = AnimElemTime(2) >= 0 && ScreenPos Y > 100
y = -.25

[State 3, 4]
type = VelSet
trigger1 = ScreenPos Y < 100
x = 0
y = 0

[State 3, 5]
type = ChangeState
trigger1 = ScreenPos Y < 100
value = 4
;---------------------------------------------------------------------------
;Lakitu
[Statedef 4]
type = A
physics = N
anim = 4
sprpriority = 0
ctrl = 0

[State 4, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 4, 2]
type = VelSet
trigger1 = PrevStateNo = 3 && !Time
trigger2 = Vel X > 1.2
x = 1.2

[State 4, 2]
type = VelSet
trigger1 = BackEdgeDist < 0
x = Vel X * -1

[State 4, 3]
type = Turn
trigger1 = PrevStateNo = 3 && !Time
trigger2 = BackEdgeDist < 0

[State 4, 4]
type = VelAdd
trigger1 = ScreenPos X > 360 || ScreenPos X < -30
x = -.8

[State 4, 5]
type = VelAdd
trigger1 = Vel X < -1.2 && (ScreenPos X >= -30 && ScreenPos X <= 360)
x = .5

[State 4, 5]
type = ParentVarSet
trigger1 = 1
var(3) = var(0)

[State 4, 6]
type = ChangeState
trigger1 = Time >= 112-(40*(RoundNo = 2))-(50*(RoundNo >= 3)) && root,Var(4)
trigger1 = NumHelper(10) < (0+(2*(RoundNo = 1))+(3*(RoundNo = 2))+(4*(RoundNo >= 3))) && enemynear(0),Ctrl
value = 5

[State 4, 79]
type = ChangeState
trigger1 = RoundState = 3
value = 6
;---------------------------------------------------------------------------
;Lakitu
[Statedef 5]
type = A
physics = N
anim = 5
sprpriority = 0
ctrl = 0

[State 5, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 5, 2]
type = VelSet
trigger1 = PrevStateNo = 3 && !Time
trigger2 = Vel X > 1.2
x = 1.2

[State 5, 3]
type = VelSet
trigger1 = BackEdgeDist < 0
x = Vel X * -1

[State 5, 4]
type = Turn
trigger1 = PrevStateNo = 3 && !Time
trigger2 = BackEdgeDist < 0

[State 5, 5]
type = VelAdd
trigger1 = ScreenPos X > 360 || ScreenPos X < -30
x = -.8

[State 5, 6]
type = VelAdd
trigger1 = Vel X < -1.2 && (ScreenPos X >= -30 && ScreenPos X <= 360)
x = .5

[State 5, 7]
type = Helper
trigger1 = AnimElem = 2
name = "Spiny"
ID = 10
stateno = 10+(10*(Random <= 499))
pos = 0,-12
postype = p1
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

[State 5, 8]
type = ParentVarSet
trigger1 = 1
var(3) = var(0)

[State 5, 9]
type = ParentVarAdd
trigger1 = AnimElem = 2
var(4) = -1

[State 5, 10]
type = PlaySnd
trigger1 = AnimElem = 2
value = S1000,0

[State 5, 11]
type = ChangeState
trigger1 = !AnimTime
value = 4
;---------------------------------------------------------------------------
;Lakitu
[Statedef 6]
type = A
physics = N
anim = 4
sprpriority = 0
ctrl = 0

[State 5, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 5, 2]
type = VelSet
trigger1 = !Time
y = 3.8

[State 5, 4]
type = Turn
trigger1 = P2Dist X < 0

[State 5, 5]
type = VelAdd
trigger1 = ScreenPos X > 360 || ScreenPos X < -30
x = -.8

[State 5, 6]
type = ParentVarSet
trigger1 = 1
var(3) = var(0)

[State 5, 7]
type = VelAdd
trigger1 = Vel Y > 0
y = -.25

[State 5, 8]
type = VelSet
trigger1 = Vel Y <= 0
x = 0
y = 0

[State 5, 9]
type = ChangeAnim
trigger1 = RoundState = 4 && Anim = 4
value = ifelse((root,Var(3) < ((0+(10*(RoundNo = 1))+(20*(RoundNo = 2))+(30*(RoundNo >= 3)))/2)), 7,8)

;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 10]
type = A
movetype = A
physics = N
anim = 10
velset = 0,-5.75
sprpriority = 0
ctrl = 0

[State 10, 1]
type = Turn
trigger1 = Facing = -1

[State 10, 2]
type = VelSet
trigger1 = !Time
x = P2Dist X/60

[State 10, 3]
type = ScreenBound
trigger1 = 1
value = 0

[State 10, 4]
type = VarSet
trigger1 = !Time
fvar(0) = -5.75 

[State 10, 5]
type = VarAdd
trigger1 = Vel Y > 0 && Pos Y >= 0
var(1) = 1

[State 10, 6]
type = VelSet
trigger1 = Vel Y > 0 && Pos Y >= 0 && Var(1) < 6
y = fvar(0) := fVar(0)/1.2

[State 10, 7]
type = VelAdd
trigger1 = (Pos Y < 0 && Var(1) < 6) || Var(1) >= 6
y = .35

[State 10, 8]
type = PosSet
trigger1 = Vel Y > 0 && Pos Y >= 0 && Var(1) < 6
y = 0

[State 10, 9]
type = VelSet
trigger1 = BackEdgeDist < 0 && Vel X < 0 || FrontEdgeDist < 0  && Vel X > 0
trigger2 = MoveContact = 1
x = Vel X * -1

[State 10, 10]
type = NotHitBy
trigger1 = 1
value = ,AT
time = 1

[State 10, 11]
type = HitOverride
trigger1 = 1
attr = SCA,AA,AP
time = -1
stateno = 11

[State 10, 12]
type = HitDef
trigger1 = 1
attr = S,NA
hitflag = MAF-
guardflag = MA
animtype = Medium
priority = 1,Hit
damage = 0,0
pausetime = 7,7
sparkno = S6001
guard.sparkno = -1
sparkxy = -9,-17*floor(const(size.yscale))
hitsound = S5,2
guardsound = S6,0
ground.type = High
ground.slidetime = 16
guard.slidetime = 12
ground.hittime = 28
guard.hittime = 28
ground.velocity = -2.6*const(size.xscale)*(Cond(Vel X != 0, Vel X/abs(Vel X), 1))
air.type = High
air.hittime = 100
air.velocity = -2.1, -1.2
fall = 1
fall.recover = 0
id = 210
chainID = -1
nochainID = -1
hitonce = 0
kill = 1
guard.kill = 1
fall.kill = 1
numhits = 1
getpower = 40,20
givepower = 20,10

[State 10, 13]
type = StateTypeSet
trigger1 = MoveContact = 1
movetype = I
ignorehitpause = 1

[State 10, 14]
type = VarAdd
trigger1 = MoveType = I && Var(0) < 100
var(0) = 1 

[State 10, 15]
type = StateTypeSet
trigger1 = Var(0) >= 100
movetype = A

[State 10, 16]
type = VarSet
trigger1 = MoveType = A && Var(0) = 100
var(0) = 0

[State 10, 17]
type = DestroySelf
trigger1 = ScreenPos Y >= 300

;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 11]
type = A
movetype = H
physics = N
anim = 1
velset = Vel X * -1,-6.66
sprpriority = 0
ctrl = 0

[State 11, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 11, 2]
type = Explod
trigger1 = !Time
anim = 10
ID = 10
pos = 0,0
postype = p1
facing = 1
vfacing = 1
bindtime = 1
vel = Vel X,-6.66
accel = 0,.35
removetime = 200
pausemovetime = 0
scale = 1,1
sprpriority = 0
ownpal = 1
removeongethit = 1

[State 11, 3]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 11, 4]
type = Explod
trigger1 = !Time
anim = 15
ID = 15
pos = 0,-32
postype = p1
facing = IfElse(Facing = 1,1,-1)
vfacing = 1
bindtime = 1
vel = 0,-3
ownpal = 1
sprpriority = 99

[State 11, 5]
type = ParentVarAdd
trigger1 = !Time
var(0) = 1

[State 11, 6]
type = DestroySelf
trigger1 = Time = 1
;---------------------------------------------------------------------------
;Red Spiny Egg
[Statedef 20]
type = A
movetype = A
physics = N
anim = 20
velset = 0,-5.75
sprpriority = 0
ctrl = 0

[State 20, 1]
type = VarSet
trigger1 = !Time
var(1) = (Random <= 10)

[State 20, 2]
type = ChangeAnim
trigger1 = Var(1)
value = 30

[State 20, 3]
type = ScreenBound
trigger1 = 1
value = 0

[State 20, 4]
type = VelAdd
trigger1 = 1
y = .35

[State 20, 5]
type = NotHitBy
trigger1 = 1
value = ,AT
time = 1

[State 20, 6]
type = HitOverride
trigger1 = 1
attr = SCA,AA,AP
time = -1
stateno = 23

[State 20, 7]
type = HitDef
trigger1 = 1
attr = S,NA
hitflag = MAF-
guardflag = MA
animtype = Medium
priority = 1,Hit
damage = 0,0
pausetime = 7,7
sparkno = S6001
guard.sparkno = -1
sparkxy = -9,-17*floor(const(size.yscale))
hitsound = S5,2
guardsound = S6,0
ground.type = High
ground.slidetime = 16
guard.slidetime = 12
ground.hittime = 28
guard.hittime = 28
ground.velocity = -2.6*const(size.xscale)
air.type = High
air.hittime = 100
air.velocity = -2.1, -1.2
fall = 1
fall.recover = 0
id = 210
chainID = -1
nochainID = -1
hitonce = 0
kill = 1
guard.kill = 1
fall.kill = 1
numhits = 1
getpower = 40,20
givepower = 20,10

[State 20, 8]
type = ChangeState
trigger1 = Vel Y > 0 && Pos Y >= 0 
value = 21
;---------------------------------------------------------------------------
;Red Spiny Egg
[Statedef 21]
type = S
movetype = I
physics = N
anim = 21+(10*Var(1))
velset = 0,0
sprpriority = 0
ctrl = 0

[State 21, 1]
type = PosSet
trigger1 = !Time
y = 0 

[State 21, 2]
type = ScreenBound
trigger1 = 1
value = 0

[State 21, 3]
type = NotHitBy
trigger1 = 1
value = ,AT
time = 1

[State 21, 4]
type = HitOverride
trigger1 = 1
attr = SCA,AA,AP
time = 1
stateno = 23

[State 21, 5]
type = PlaySnd
trigger1 = !Time
value = S1000,1

[State 21, 6]
type = ChangeState
trigger1 = !AnimTime
value = 22
;---------------------------------------------------------------------------
;Spiny
[Statedef 22]
type = S
movetype = A
physics = N
anim = 22+(10*Var(1))
sprpriority = 0
ctrl = 0

[State 22, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 22, 2]
type = VelSet
trigger1 = !Time
x = 1

[State 22, 3]
type = VelSet
trigger1 = P2Dist X <= 0 && !Time
x = Vel X * -1

[State 22, 4]
type = Turn
trigger1 = P2Dist X <= 0 && !Time

[State 22, 5]
type = HitBy
trigger1 = 1
value = SCA,AA,AP
time = 1

[State 22, 6]
type = NotHitBy
trigger1 = P2StateType = A
value = ,AA
time = 1

[State 22, 7]
type = HitOverride
trigger1 = 1
attr = SCA,AA,AP
time = -1
stateno = 23

[State 22, 8]
type = HitDef
trigger1 = 1
attr = S,NA
hitflag = MAF-
guardflag = MA
animtype = Medium
priority = 1,Hit
damage = 0,0
pausetime = 7,7
sparkno = S6001
guard.sparkno = -1
sparkxy = -9,-17*floor(const(size.yscale))
hitsound = S5,2
guardsound = S6,0
ground.type = High
ground.slidetime = 16
guard.slidetime = 12
ground.hittime = 28
guard.hittime = 28
ground.velocity = -2.6*const(size.xscale)
air.type = High
air.hittime = 100
air.velocity = -2.1, -1.2
fall = 1
fall.recover = 0
id = 210
chainID = -1
nochainID = -1
hitonce = 0
kill = 1
guard.kill = 1
fall.kill = 1
numhits = 1
getpower = 40,20
givepower = 20,10

[State 22, 9]
type = StateTypeSet
trigger1 = MoveContact = 1
movetype = I

[State 22, 10]
type = VarAdd
trigger1 = MoveType = I && Var(0) < 100
var(0) = 1 

[State 22, 11]
type = StateTypeSet
trigger1 = Var(0) >= 100
movetype = A

[State 22, 12]
type = VarSet
trigger1 = MoveType = A && Var(0) = 100
var(0) = 0

[State 22, 13]
type = DestroySelf
trigger1 = FrontEdgeDist < -40

;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 23]
type = A
movetype = H
physics = N
anim = 1
velset = Vel X * -1,-6.66
sprpriority = 0
ctrl = 0

[State 11, 1]
type = ScreenBound
trigger1 = 1
value = 0

[State 11, 2]
type = Explod
trigger1 = !Time
anim = 23+(10*Var(1))
ID = 10
pos = 0,0
postype = p1
facing = 1
vfacing = 1
bindtime = 1
vel = Vel X,-6.66
accel = 0,.35
removetime = 200
pausemovetime = 0
scale = 1,1
sprpriority = 0
ownpal = 1
removeongethit = 1

[State 11, 3]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 11, 4]
type = Explod
trigger1 = !Time
anim = 25
ID = 25
pos = 0,-32
postype = p1
facing = IfElse(Facing = 1,1,-1)
vfacing = 1
bindtime = 1
vel = 0,-3
ownpal = 1
sprpriority = 99

[State 11, 5]
type = ParentVarAdd
trigger1 = !Time
var(0) = 1

[State 11, 6]
type = DestroySelf
trigger1 = Time = 1

;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 60]
type = A
movetype = A
physics = N
anim = 60
velset = 0,0
sprpriority = 0
ctrl = 0

[State 60, 1]
type = HitDef
Trigger1 = !Time
attr = S, NT
hitflag = MAFD
priority = 1, Hit
sparkno = -1
p1sprpriority = 1
p1facing = 1
p2facing = 1
p1stateno = 61
p2stateno = 62
guard.dist = 0

[State 11, 3]
type = Null
trigger1 = Time = 1
;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 61]
type = A
movetype = A
physics = N
anim = 1
velset = 0,0
sprpriority = 0
ctrl = 0

[State 61, 1]
type = TargetLifeAdd
trigger1 = NumTarget
value = target,Life * -1 
;---------------------------------------------------------------------------
;Spiny Egg
[Statedef 62]
type = U
movetype = H
physics = U

[State 62, 1]
type = SelfState
trigger1 = !Time
value = 5050
